package server;

import static constant.Constant.PORT;
import static constant.Constant.STR_ERR_LISTEN;
import static constant.Constant.STR_SERVER_CLOSED;
import static constant.Constant.STR_SERVER_STARTED;

import java.io.IOException;
import java.net.ServerSocket;

public class MultiServer {
	public static void main(String[] args) throws IOException {

		ServerSocket serverSocket = null;
		boolean listening = true;

		try {
			serverSocket = new ServerSocket(PORT);
			System.out.println(STR_SERVER_STARTED);
		} catch (IOException e) {
			System.err.println(STR_ERR_LISTEN);
			System.exit(-1);
		}
		while (listening) {
			new MultiServerThread(serverSocket.accept()).start();
		}
		serverSocket.close();
		System.out.println(STR_SERVER_CLOSED);
	}
}